package com.yfunc.ibatis3;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

public interface SqlRepository {

	int insert(Object entity);

	int update(Object entity);

	int delete(Object entity);

	int delete(Class<?> entityClass, Object pk);

	<T> T load(Class<?> entityClass, Object pk);

	<T> List<T> loadAll(Class<?> entityClass);

	SqlSessionFactory getSqlSessionFactory();

	<T> int doUpdate(UpdateHandler<T> handler);

	<T> T doQuery(QueryHandler<T> handler);

	interface QueryHandler<T> {
		T query(SqlSession session);
	}
	interface UpdateHandler<T> {
		int update(SqlSession session);
	}

}
